<?php

/**
 * This is the model class for table "sysusrsecurity".
 *
 * The followings are the available columns in table 'sysusrsecurity':
 * @property string $CredentialName
 * @property string $HumanID
 * @property string $Password
 * @property integer $MenuGroupID
 * @property integer $LevelID
 * @property string $ExpiredDate
 * @property string $LastLoginOn
 * @property string $LastLoginOnIP
 * @property string $LastLoginOnPC
 * @property integer $isLocked
 * @property string $CreatedBy
 * @property string $CreatedOn
 * @property string $LastUpdateBy
 * @property string $LastUpdateOn
 *
 * The followings are the available model relations:
 * @property Invhuman $human
 * @property Sysusrlevel $level
 * @property Sysappmenugroup $menuGroup
 */
class Sysusrsecurity extends CActiveRecord
{
    public $menugroupname;
    public $companyid;
    public $companyname;
    public $companybranchid;
    public $companybranchname;
    public $aliasname;
    public $asd;
    /**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'sysusrsecurity';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('credentialname, password, menugroupid, expireddate, islocked, createdby, createdon', 'required'),
			array('menugroupid, levelid, islocked', 'numerical', 'integerOnly'=>true),
			array('credentialname, lastloginonip, lastloginonpc, createdby, lastupdateby', 'length', 'max'=>50),
			array('name', 'length', 'max'=>100),
			array('password', 'length', 'max'=>255),
			array('lastloginon, lastupdateon', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('credentialname, name, password, menugroupid, levelid, expireddate, lastloginon, lastloginonip, lastloginonpc, islocked, createdby, createdon, lastupdateby, lastupdateon', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(			
			'level' => array(self::BELONGS_TO, 'sysusrlevel', 'levelid'),
			'menugroup' => array(self::BELONGS_TO, 'sysappmenugroup', 'menugroupid'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'credentialname' => 'Credential Name',
			'name' => 'Name',
			'password' => 'Password',
			'menugroupid' => 'Menu Group',
			'levelid' => 'Level',
			'expireddate' => 'Expired Date',
			'lastloginon' => 'Last Login On',
			'lastloginonip' => 'Last Login On Ip',
			'lastloginonpc' => 'Last Login On Pc',
			'islocked' => 'Is Locked',
			'createdby' => 'Created By',
			'createdon' => 'Created On',
			'lastupdateby' => 'Last Update By',
			'lastupdateon' => 'Last Update On',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('credentialname',$this->credentialname,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('password',$this->password,true);
		$criteria->compare('menugroupid',$this->menugroupid);
		$criteria->compare('levelid',$this->levelid);
		$criteria->compare('expireddate',$this->expireddate,true);
		$criteria->compare('lastloginon',$this->lastloginon,true);
		$criteria->compare('lastloginonip',$this->lastloginonip,true);
		$criteria->compare('lastloginonpc',$this->lastloginonpc,true);
		$criteria->compare('isLocked',$this->isLocked);
		$criteria->compare('createdby',$this->createdby,true);
		$criteria->compare('createdon',$this->createdon,true);
		$criteria->compare('lastupdateby',$this->lastupdateby,true);
		$criteria->compare('lastupdateon',$this->lastupdateon,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Sysusrsecurity the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
